<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>短链跳转</title>
    <script>
        var url = "https://gitee.com/api/v5/repos/mdkml/mdkml/issues/I456C5/comments";

        var map = new Map();

        function redirect() {
            var location = window.location;
            var urlNumber = location.pathname.split("/")[1];
            var homepage = "https://mdkml.gitee.io";
            var xhr = new XMLHttpRequest();

            xhr.onload = function () {
                try {
                    var payload = JSON.parse(xhr.response);
                    for (let payloadElement of payload) {
                        var arr = payloadElement.body.split("=")
                        map.set(arr[0], arr[1]);
                    }
                    var url = map.get(urlNumber);

                    if (!url) {
                        location.replace(homepage);
                    } else {
                        location.replace(url);
                    }
                } catch (e) {
                    location.replace(homepage);
                }
            };

            xhr.onerror = function () {
                location.replace(homepage);
            };
            xhr.open("GET", url);
            xhr.send();
        }

        redirect();
    </script>
</head>
<body></body>
</html>